package blackithei.TCP;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class ServerDemo4 {
    public static void main(String[] args) throws IOException {
        ServerSocket so=new ServerSocket(10001);
        while (true) {
            Socket accept = so.accept();
            //网络流
            BufferedInputStream bf=new BufferedInputStream(accept.getInputStream());
            //本地流 写数据
            BufferedOutputStream buf=new BufferedOutputStream(new FileOutputStream("day15\\aaa1"));
            int by;
            while((by=bf.read())!=-1){
                buf.write(by);
            }

            //反馈
            BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(accept.getOutputStream()));
            bw.write("收到了");
            bw.close();

            bf.close();
            accept.close();
        }
        //so.close();
    }
}
